/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 更新玩家基本信息
	/// module : structs
	/// </summary>
	public class UpdatePlayerInfoPOD : IPOD 
    {
        public readonly static Func<UpdatePlayerInfoPOD> FACTORY = () => new UpdatePlayerInfoPOD();
		public static Func<UpdatePlayerInfoPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public PlayerInfoKey key;
		/// <summary>
        /// 
        /// </summary>
		public int intValue;
		/// <summary>
        /// 
        /// </summary>
		public string stringValue;
		
		
		
		/*-- constructors --*/
		public UpdatePlayerInfoPOD() {}
		public UpdatePlayerInfoPOD(PlayerInfoKey key, int intValue, string stringValue) {
			this.key = key;
			this.intValue = intValue;
			this.stringValue = stringValue;
		}
		  public void Serial(SOutputStream _out) {
                if(key != default) {
                    _out.WriteByte(1);
                    _out.Write_byte((sbyte)key);
                }
                if(intValue != default) {
                    _out.WriteByte(2);
                    _out.Write_int(intValue);
                }
                if(stringValue != default) {
                    _out.WriteByte(3);
                    _out.Write_string(stringValue);
                }
        }
            
        public void UnSerial(SInputStream _in) {
            while (_in.HasRemaining())
            {
                int _key = _in.ReadByte();
                switch (_key)
                {
                    case 1:
                        key = (PlayerInfoKey)_in.Read_byte();
                        break;
                    case 2:
                        intValue = _in.Read_int();
                        break;
                    case 3:
                        stringValue = _in.Read_string();
                        break;
                    default: _in.SkipBinary();break;
                }
            }
        }
		
		public UpdatePlayerInfoPOD Clone() {
            UpdatePlayerInfoPOD o = DynamicFactory();
            o.key = key;
            o.intValue = intValue;
            o.stringValue = stringValue;
            return o;
        }
        
        public void Clear() {
            key = default;
            intValue = default;
            stringValue = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "UpdatePlayerInfoPOD [";
			str += "key=";
			str += key;
			str += ", intValue=";
			str += intValue;
			str += ", stringValue=";
			str += stringValue;
			str += "]";
			return str;
		}
		
	}
}